package com.crealth.model;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONArray;


public class ConsumerInfoModel implements Serializable {
	private static final long serialVersionUID = 1591045L;
	
	public static final int FollowUp = 0;  // 跟单
	public static final int Submit_Already = 1;  // 已提交
	//public static final int Send_Back = 2;  // 回退
	public static final int Contract_Saved = 3;  // 合同已录入
	public static final int Contract_Printed = 4;  // 合同已打印
	public static final int Contract_Signed = 5;  // 合同已签
	public static final int Contract_Accepted = 6;  // 按揭经理已经接收
	
	public static final int Flow_KFJL = 11;  //  流程跟进  客户经理
	public static final int Flow_KF = 12;  //  客服
	public static final int Flow_Signed = 13;  //  已签约
	public static final int Flow_AJ = 14;  //  按揭经理
	public static final int Flow_FKWW = 15;  //  放款未完
	public static final int Flow_FKWB = 16;  //  放款完毕
	public static final int Flow_Back = 17;  //  回退
	
	private int id;
	private int belongCompany;
	private int userID;
	private String name;
	private String phoneNum1;
	private String phoneNum2;
	private String identityID;
    private int age;
    private int isSZHousehold;
    private int credit;
    private int loanCreditNum; 
	private String loanCreditSum;
	private String loanCreditDue;
	private String loanCredirMonthPay;
	private int pettyLoanNum;
	private String pettyLoanSum;
	private String pettyLoanDue;
	private String pettyLoanMonthPay;
	private int creditCardNum;
	private String creditCardSum;
	private String creditCardUsed;
	private String creditCardMonthPay;
	private String cliType;
	private String followupInfo;
	private Timestamp submitTm;
	private Timestamp meetTalkTm;
	private int needMoney;
	private int loanUse;
	private int needTime;
	private int mateOpinion;
	private String memo;
	private Timestamp devTime;	
	private int cliLevel;
	private String leaderGuide;
	private String leaderMemo;
	private Timestamp lastfollowupTm;
	private Timestamp lastModifyTm;
	private int status;
	private int flowFollow;
	private Timestamp signContractTm;
	
	public ConsumerInfoModel() {
		name = "";
		phoneNum1 = "";
		phoneNum2 = "";
		identityID = "";
		loanCreditSum = "";
		loanCreditDue = "";
		loanCredirMonthPay = "";
		pettyLoanSum = "";
		pettyLoanDue = "";
		pettyLoanMonthPay = "";
		creditCardSum = "";
		creditCardUsed = "";
		creditCardMonthPay = "";
		followupInfo = "";
		memo = "";
		age = -1;
		isSZHousehold = -1;
		credit = -1;
		loanCreditNum = -1;
		pettyLoanNum = -1;
		creditCardNum = -1;
		cliType = "";
		needMoney = -1;
		loanUse = -1;
		needTime = -1;
		mateOpinion = -1;
		userID = -1;
		belongCompany = -1;
		cliLevel = -1;
		leaderGuide = "";
		leaderMemo = "";
		meetTalkTm = null;
		submitTm = null; 
		status = 0;
		flowFollow = 0;
		signContractTm = null;
	}
	
	private List<ConsumerHouseModel> housels;
	private List<ConsumerCarModel> carls;
	private List<ConsumerPolicyModel> policyls;
	private ConsumerWorkModel workModel;
	private ConsumerSelfModel selfModel;
	private List<ConsumerLoanModel> loanls;
	private List<ConsumerCreditCardModel> creditCardls;
	private List<ConsumerFollowupModel> followupls;
	private List<ConsumerNextFollowupModel> nextFollowupls;
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
		if (housels != null) {
			for (ConsumerHouseModel houseModel : housels) {
				houseModel.setConsumerID(id);
			}
		}
		if (carls != null) {
			for (ConsumerCarModel carModel : carls) {
				carModel.setConsumerID(id);
			}
		}
		if (policyls != null) {
			for (ConsumerPolicyModel policyModel : policyls) {
				policyModel.setConsumerID(id);
			}
		}
		if (workModel != null) {
			workModel.setConsumerID(id);
		}
		if (selfModel != null) {
			selfModel.setConsumerID(id);
		}
		if (loanls != null) {
			for (ConsumerLoanModel loanModel : loanls) {
				loanModel.setConsumerID(id);
			}
		}
		if (creditCardls != null) {
			for (ConsumerCreditCardModel creditCard : creditCardls) {
				creditCard.setConsumerID(id);
			}
		}
	}
	
	public int getBelongCompany() {
		return belongCompany;
	}
	public void setBelongCompany(int belongCompany) {
		this.belongCompany = belongCompany;
	}
	public int getUserID() {
		return userID;
	}
	public void setUserID(int userID) {
		this.userID = userID;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPhoneNum1() {
		return phoneNum1;
	}
	public void setPhoneNum1(String phoneNum1) {
		this.phoneNum1 = phoneNum1;
	}
	public String getPhoneNum2() {
		return phoneNum2;
	}
	public void setPhoneNum2(String phoneNum2) {
		this.phoneNum2 = phoneNum2;
	}
	public String getIdentityID() {
		return identityID;
	}
	public void setIdentityID(String identityID) {
		this.identityID = identityID;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public int getIsSZHousehold() {
		return isSZHousehold;
	}
	public void setIsSZHousehold(int isSZHousehold) {
		this.isSZHousehold = isSZHousehold;
	}
	public int getCredit() {
		return credit;
	}
	public void setCredit(int credit) {
		this.credit = credit;
	}
	public int getLoanCreditNum() {
		return loanCreditNum;
	}
	public void setLoanCreditNum(int loanCreditNum) {
		this.loanCreditNum = loanCreditNum;
	}
	public String getLoanCreditSum() {
		return loanCreditSum;
	}
	public void setLoanCreditSum(String loanCreditSum) {
		this.loanCreditSum = loanCreditSum;
	}
	public String getLoanCreditDue() {
		return loanCreditDue;
	}
	public void setLoanCreditDue(String loanCreditDue) {
		this.loanCreditDue = loanCreditDue;
	}
	public String getLoanCredirMonthPay() {
		return loanCredirMonthPay;
	}
	public void setLoanCredirMonthPay(String loanCredirMonthPay) {
		this.loanCredirMonthPay = loanCredirMonthPay;
	}
	public int getPettyLoanNum() {
		return pettyLoanNum;
	}
	public void setPettyLoanNum(int pettyLoanNum) {
		this.pettyLoanNum = pettyLoanNum;
	}
	public String getPettyLoanSum() {
		return pettyLoanSum;
	}
	public void setPettyLoanSum(String pettyLoanSum) {
		this.pettyLoanSum = pettyLoanSum;
	}
	public String getPettyLoanDue() {
		return pettyLoanDue;
	}
	public void setPettyLoanDue(String pettyLoanDue) {
		this.pettyLoanDue = pettyLoanDue;
	}
	public String getPettyLoanMonthPay() {
		return pettyLoanMonthPay;
	}
	public void setPettyLoanMonthPay(String pettyLoanMonthPay) {
		this.pettyLoanMonthPay = pettyLoanMonthPay;
	}
	public int getCreditCardNum() {
		return creditCardNum;
	}
	public void setCreditCardNum(int creditCardNum) {
		this.creditCardNum = creditCardNum;
	}
	public String getCreditCardSum() {
		return creditCardSum;
	}
	public void setCreditCardSum(String creditCardSum) {
		this.creditCardSum = creditCardSum;
	}
	public String getCreditCardUsed() {
		return creditCardUsed;
	}
	public void setCreditCardUsed(String creditCardUsed) {
		this.creditCardUsed = creditCardUsed;
	}
	public String getCreditCardMonthPay() {
		return creditCardMonthPay;
	}
	public void setCreditCardMonthPay(String creditCardMonthPay) {
		this.creditCardMonthPay = creditCardMonthPay;
	}
	public String getCliType() {
		return cliType;
	}
	public void setCliType(String cliType) {
		this.cliType = cliType;
	}
	public String getFollowupInfo() {
		return followupInfo;
	}
	public void setFollowupInfo(String followupInfo) {
		this.followupInfo = followupInfo;
	}
	public Timestamp getSubmitTm() {
		return submitTm;
	}
	public void setSubmitTm(Timestamp submitTm) {
		this.submitTm = submitTm;
	}	
	public Timestamp getMeetTalkTm() {
		return meetTalkTm;
	}
	public void setMeetTalkTm(Timestamp meetTalkTm) {
		this.meetTalkTm = meetTalkTm;
	}
	public int getNeedMoney() {
		return needMoney;
	}
	public void setNeedMoney(int needMoney) {
		this.needMoney = needMoney;
	}
	public int getLoanUse() {
		return loanUse;
	}
	public void setLoanUse(int loanUse) {
		this.loanUse = loanUse;
	}
	public int getNeedTime() {
		return needTime;
	}
	public void setNeedTime(int needTime) {
		this.needTime = needTime;
	}
	public int getMateOpinion() {
		return mateOpinion;
	}
	public void setMateOpinion(int mateOpinion) {
		this.mateOpinion = mateOpinion;
	}
	public String getMemo() {
		return memo;
	}
	public void setMemo(String memo) {
		this.memo = memo;
	}	
	public Timestamp getDevTime() {
		return devTime;
	}
	public void setDevTime(Timestamp devTime) {
		this.devTime = devTime;
	}	
	public int getCliLevel() {
		return cliLevel;
	}
	public void setCliLevel(int cliLevel) {
		this.cliLevel = cliLevel;
	}
	public String getLeaderGuide() {
		return leaderGuide;
	}
	public void setLeaderGuide(String leaderGuide) {
		this.leaderGuide = leaderGuide;
	}
	public String getLeaderMemo() {
		return leaderMemo;
	}
	public void setLeaderMemo(String leaderMemo) {
		this.leaderMemo = leaderMemo;
	}
	public List<ConsumerHouseModel> getHousels() {
		return housels;
	}
	public void setHousels(List<ConsumerHouseModel> housels) {
		this.housels = housels;
	}
	public List<ConsumerCarModel> getCarls() {
		return carls;
	}
	public void setCarls(List<ConsumerCarModel> carls) {
		this.carls = carls;
	}
	public List<ConsumerPolicyModel> getPolicyls() {
		return policyls;
	}
	public void setPolicyls(List<ConsumerPolicyModel> policyls) {
		this.policyls = policyls;
	}
	public ConsumerWorkModel getWorkModel() {
		return workModel;
	}
	public void setWorkModel(ConsumerWorkModel workModel) {
		this.workModel = workModel;
	}
	public ConsumerSelfModel getSelfModel() {
		return selfModel;
	}
	public void setSelfModel(ConsumerSelfModel selfModel) {
		this.selfModel = selfModel;
	}
	public List<ConsumerLoanModel> getLoanls() {
		return loanls;
	}
	public void setLoanls(List<ConsumerLoanModel> loanls) {
		this.loanls = loanls;
	}
	public List<ConsumerCreditCardModel> getCreditCardls() {
		return creditCardls;
	}
	public void setCreditCardls(List<ConsumerCreditCardModel> creditCardls) {
		this.creditCardls = creditCardls;
	}	
	public List<ConsumerFollowupModel> getFollowupls() {
		return followupls;
	}
	public void setFollowupls(List<ConsumerFollowupModel> followupls) {
		this.followupls = followupls;
	}	
	public Timestamp getLastfollowupTm() {
		return lastfollowupTm;
	}
	public void setLastfollowupTm(Timestamp lastfollowupTm) {
		this.lastfollowupTm = lastfollowupTm;
	}	
	public Timestamp getLastModifyTm() {
		return lastModifyTm;
	}
	public void setLastModifyTm(Timestamp lastModifyTm) {
		this.lastModifyTm = lastModifyTm;
	}
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}	
	public int getFlowFollow() {
		return flowFollow;
	}
	public void setFlowFollow(int flowFollow) {
		this.flowFollow = flowFollow;
	}	
	public List<ConsumerNextFollowupModel> getNextFollowupls() {
		return nextFollowupls;
	}
	public void setNextFollowupls(List<ConsumerNextFollowupModel> nextFollowupls) {
		this.nextFollowupls = nextFollowupls;
	}	
	public Timestamp getSignContractTm() {
		return signContractTm;
	}
	public void setSignContractTm(Timestamp signContractTm) {
		this.signContractTm = signContractTm;
	}
	
	public void parseFromJson(JSONObject jsonData) {
		this.name = jsonData.getString("cliName");
		this.phoneNum1 = jsonData.getString("cliPhoneNum1");
		if (jsonData.containsKey("consumerID")) {
			this.id = jsonData.getIntValue("consumerID");
		}
		if (jsonData.containsKey("cliPhoneNum2")) {
			this.phoneNum2 = jsonData.getString("cliPhoneNum2");
		}
		if (jsonData.containsKey("identityID")) {
			this.identityID = jsonData.getString("identityID");
		}
		if (jsonData.containsKey("age")) {
			this.age = jsonData.getIntValue("age");
		}
		if (jsonData.containsKey("isSZhukou")) {
			this.isSZHousehold = jsonData.getIntValue("isSZhukou");
		}
		if (jsonData.containsKey("creditStatus")) {
			this.credit = jsonData.getIntValue("creditStatus");
		}
		if (jsonData.containsKey("memo")) {
			this.memo = jsonData.getString("memo");
		}
		if (jsonData.containsKey("cliType")) {
			this.cliType = jsonData.getString("cliType");
		}
		if (jsonData.containsKey("followupRecord")) {
			this.followupInfo = jsonData.getString("followupRecord");
		}
		if (jsonData.containsKey("needMoney")) {
			this.needMoney = jsonData.getIntValue("needMoney");
		}
		if (jsonData.containsKey("loanUse")) {
			this.loanUse = jsonData.getIntValue("loanUse");
		}
		if (jsonData.containsKey("needTime")) {
			this.needTime = jsonData.getIntValue("needTime");
		}
		if (jsonData.containsKey("mateIdea")) {
			this.mateOpinion = jsonData.getIntValue("mateIdea");
		}
		if (jsonData.containsKey("submitTm")) {
			long tm = jsonData.getLongValue("submitTm")*1000;
			this.submitTm = new Timestamp(tm);
		}
		
		//  负债  总计
		if (jsonData.containsKey("creditLoanNum")) {
			this.loanCreditNum = jsonData.getIntValue("creditLoanNum");
		}
		if (jsonData.containsKey("creditLoanSum")) {
			this.loanCreditSum = jsonData.getString("creditLoanSum");
		}
		if (jsonData.containsKey("creditLoanDueSum")) {
			this.loanCreditDue = jsonData.getString("creditLoanDueSum");
		}
		if (jsonData.containsKey("creditLoanMonthPay")) {
			this.loanCredirMonthPay = jsonData.getString("creditLoanMonthPay");
		}		
		if (jsonData.containsKey("pettyLoanNum")) {
			this.pettyLoanNum = jsonData.getIntValue("pettyLoanNum");
		}
		if (jsonData.containsKey("pettyLoanSum")) {
			this.pettyLoanSum = jsonData.getString("pettyLoanSum");
		}
		if (jsonData.containsKey("pettyLoanDueSum")) {
			this.pettyLoanDue = jsonData.getString("pettyLoanDueSum");
		}
		if (jsonData.containsKey("pettyLoanMonthPay")) {
			this.pettyLoanMonthPay = jsonData.getString("pettyLoanMonthPay");
		}		
		if (jsonData.containsKey("creditCardNum")) {
			this.creditCardNum = jsonData.getIntValue("creditCardNum");
		}
		if (jsonData.containsKey("creditCardLimitSum")) {
			this.creditCardSum = jsonData.getString("creditCardLimitSum");
		}
		if (jsonData.containsKey("creditCardUsedSum")) {
			this.creditCardUsed = jsonData.getString("creditCardUsedSum");
		}
		if (jsonData.containsKey("creditCard10Sum")) {
			this.creditCardMonthPay = jsonData.getString("creditCard10Sum");
		}
		
		if (jsonData.containsKey("houseJson")) {			
			String strjson = jsonData.getString("houseJson");
			JSONArray jsonArray = JSONArray.parseArray(strjson);
			for (int i = 0; i < jsonArray.size(); ++i) {
				JSONObject houseJson = jsonArray.getJSONObject(i);
				ConsumerHouseModel houseModel = new ConsumerHouseModel();
				houseModel.parseFromJson(houseJson);
				if (housels == null) {
					housels = new ArrayList<ConsumerHouseModel>();
				}
				housels.add(houseModel);
			}
		}
		
		if (jsonData.containsKey("carJson")) {
			String strjson = jsonData.getString("carJson");
			JSONArray jsonArray = JSONArray.parseArray(strjson);
			for (int i = 0; i < jsonArray.size(); ++i) {
				JSONObject carJson = jsonArray.getJSONObject(i);			
				ConsumerCarModel carModel = new ConsumerCarModel();
				carModel.parseFromJson(carJson);
				if (carls == null) {
					carls = new ArrayList<ConsumerCarModel>();
				}
				carls.add(carModel);
			}
		}
		
		if (jsonData.containsKey("policyJson")) {
			String strjson = jsonData.getString("policyJson");
			JSONArray jsonArray = JSONArray.parseArray(strjson);
			for (int i = 0; i < jsonArray.size(); ++i) {
				JSONObject policyJson = jsonArray.getJSONObject(i);			
				ConsumerPolicyModel policyModel = new ConsumerPolicyModel();
				policyModel.parseFromJson(policyJson);
				if (policyls == null) {
					policyls = new ArrayList<ConsumerPolicyModel>();
				}
				policyls.add(policyModel);
			}
		}
		
		if (jsonData.containsKey("professionJson")) {
			String strjson = jsonData.getString("professionJson");
			JSONObject professionJson = JSONObject.parseObject(strjson);
			int professionType = professionJson.getIntValue("professionType");
			if (0 == professionType || 1 == professionType) {
				workModel = new ConsumerWorkModel();
				workModel.parseFromJson(professionJson);
			}
			else {
				selfModel = new ConsumerSelfModel();
				selfModel.parseFromJson(professionJson);
			}			
		}
		
		if (jsonData.containsKey("creditLoanJson")) {
			String strjson = jsonData.getString("creditLoanJson");
			JSONArray jsonArray = JSONArray.parseArray(strjson);
			for (int i = 0; i < jsonArray.size(); ++i) {			
				JSONObject creditLoanJson = jsonArray.getJSONObject(i);
				if (loanls == null) {
					loanls = new ArrayList<ConsumerLoanModel>();
				}
				ConsumerLoanModel loanModel = new ConsumerLoanModel();
				loanModel.parseFromJson(creditLoanJson);
				loanModel.setLoanType(1);
				loanls.add(loanModel);
			}
		}
		if (jsonData.containsKey("pettyLoanJson")) {
			String strjson = jsonData.getString("pettyLoanJson");
			JSONArray jsonArray = JSONArray.parseArray(strjson);
			for (int i = 0; i < jsonArray.size(); ++i) {			
				JSONObject pettyLoanJson = jsonArray.getJSONObject(i);
				if (loanls == null) {
					loanls = new ArrayList<ConsumerLoanModel>();
				}
				ConsumerLoanModel loanModel = new ConsumerLoanModel();
				loanModel.parseFromJson(pettyLoanJson);
				loanModel.setLoanType(2);
				loanls.add(loanModel);
			}
		}
		
		if (jsonData.containsKey("creditCardJson")) {
			String strjson = jsonData.getString("creditCardJson");
			JSONArray jsonArray = JSONArray.parseArray(strjson);
			for (int i = 0; i < jsonArray.size(); ++i) {
				JSONObject creditCardJson = jsonArray.getJSONObject(i);
				if (creditCardls == null) {
					creditCardls = new ArrayList<ConsumerCreditCardModel>();
				}
				ConsumerCreditCardModel creditCard = new ConsumerCreditCardModel();
				creditCard.parseFromJson(creditCardJson);
				creditCardls.add(creditCard);
			}
		}		
	}
	
	public JSONObject toJSONObject() {
		JSONObject jsonObj = new JSONObject();
		jsonObj.put("id", this.id);
		jsonObj.put("userID", this.userID);
		jsonObj.put("cliName", this.name);
		jsonObj.put("cliPhoneNum1", phoneNum1);
		if (phoneNum2 != null && phoneNum2.length() > 0) {
			jsonObj.put("cliPhoneNum2", phoneNum2);
		}
		if (identityID != null && identityID.length() > 0) {
			jsonObj.put("identityID", identityID);
		}
		if (age > 0) {
			jsonObj.put("age", age);
		}
		if (isSZHousehold >= 0) {
			jsonObj.put("isSZhukou", isSZHousehold);
		}
		if (credit >= 0) {
			jsonObj.put("creditStatus", credit);
		}
		if (memo != null && memo.length() > 0) {
			jsonObj.put("memo", memo);
		}
		if (cliType.length() >= 0) {
			jsonObj.put("cliType", cliType);
		}
		if (followupInfo != null && followupInfo.length() > 0) {
			jsonObj.put("followupRecord", followupInfo);
		}
		if (needMoney >= 0) {
			jsonObj.put("needMoney", needMoney);
		}
		if (loanUse >= 0) {
			jsonObj.put("loanUse", loanUse);
		}
		if (needTime >= 0) {
			jsonObj.put("needTime", needTime);
		}
		if (mateOpinion >= 0) {
			jsonObj.put("mateIdea", mateOpinion);
		}
		if (submitTm != null) {
			long tm = submitTm.getTime() / 1000;
			jsonObj.put("submitTm", tm);
		}
		if (this.meetTalkTm != null) {
			long tm = this.meetTalkTm.getTime() / 1000;
			jsonObj.put("meetTalkTm", tm);
		}
		if (devTime != null) {
			long devtm = devTime.getTime() / 1000;
			jsonObj.put("devTime", devtm);
		}
		if (cliLevel >= 0) {
			jsonObj.put("cliLevel", cliLevel);
		}
		if (this.leaderGuide.length() > 0) {
			jsonObj.put("guide", leaderGuide);
		}
		if (this.leaderMemo.length() > 0) {
			jsonObj.put("leaderMemo", leaderMemo);
		}
		if (lastModifyTm != null) {
			long lasttm = lastModifyTm.getTime() / 1000;
			jsonObj.put("lastModifyTm", lasttm);
		}
		if (status > 0) {
			jsonObj.put("status", status);
		}
		if (flowFollow > 0) {
			jsonObj.put("flowFollow", flowFollow);
		}
		
		if (loanCreditNum > 0) {
			jsonObj.put("creditLoanNum", loanCreditNum);
		}
		if (loanCreditSum != null && loanCreditSum.length() > 0) {
			jsonObj.put("loanCreditSum", loanCreditSum);
		}
		if (loanCreditDue != null && loanCreditDue.length() > 0) {
			jsonObj.put("creditLoanDueSum", loanCreditDue);
		}
		if (loanCredirMonthPay != null && loanCredirMonthPay.length() > 0) {
			jsonObj.put("creditLoanMonthPay", loanCredirMonthPay);
		}		
		if (pettyLoanNum > 0) {
			jsonObj.put("pettyLoanNum", pettyLoanNum);
		}
		if (pettyLoanSum != null && pettyLoanSum.length() > 0) {
			jsonObj.put("pettyLoanSum", pettyLoanSum);
		}
		if (pettyLoanDue != null && pettyLoanDue.length() > 0) {
			jsonObj.put("pettyLoanDueSum", pettyLoanDue);
		}
		if (pettyLoanMonthPay != null && pettyLoanMonthPay.length() > 0) {
			jsonObj.put("pettyLoanMonthPay", pettyLoanMonthPay);
		}		
		if (creditCardNum > 0) {
			jsonObj.put("creditCardNum", creditCardNum);
		}
		if (creditCardSum != null && creditCardSum.length() > 0) {
			jsonObj.put("creditCardLimitSum", creditCardSum);
		}
		if (creditCardUsed != null && creditCardUsed.length() > 0) {
			jsonObj.put("creditCardUsedSum", creditCardUsed);
		}
		if (creditCardMonthPay != null && creditCardMonthPay.length() > 0) {
			jsonObj.put("creditCardMonthPay", creditCardMonthPay);
		}
		if (signContractTm != null) {
			long signTm = signContractTm.getTime() / 1000;
			jsonObj.put("signContractTm", signTm);
		}
		
		if (housels != null && housels.size() > 0) {
			JSONArray jsonArray = new JSONArray();
			for (ConsumerHouseModel houseModel : housels) {
				JSONObject houseJson = houseModel.toJSONObject();
				jsonArray.add(houseJson);
			}
			jsonObj.put("houseJson", jsonArray);
		}
		
		if (carls != null && carls.size() > 0) {
			JSONArray jsonArray = new JSONArray();
			for (ConsumerCarModel carModel : carls) {
				JSONObject carJson = carModel.toJSONObject();				
				jsonArray.add(carJson);
			}
			jsonObj.put("carJson", jsonArray);
		}
		
		if (policyls != null && policyls.size() > 0) {
			JSONArray jsonArray = new JSONArray();
			for (ConsumerPolicyModel policyModel : policyls) {
				JSONObject policyJson = policyModel.toJSONObject();
				jsonArray.add(policyJson);
			}
			jsonObj.put("policyJson", jsonArray);
		}
		
		if (workModel != null || selfModel != null) {
			JSONObject professionJson;
			int workType = 0;
			if (workModel != null) {
				professionJson = workModel.toJSONObject();
				workType = workModel.getWorkType();
			}
			else {
				professionJson = selfModel.toJSONObject();
				workType = 2;
			}
			jsonObj.put("professionJson", professionJson);
			jsonObj.put("workType", workType);
		}
		
		if (loanls != null && loanls.size() > 0) {
			JSONArray jsonArray = new JSONArray();
			for (ConsumerLoanModel loanModel : loanls) {			
				JSONObject creditLoanJson = loanModel.toJSONObject();
				jsonArray.add(creditLoanJson);
			}
			jsonObj.put("loanJson", jsonArray);
		}
		
		if (creditCardls != null && creditCardls.size() > 0) {
			JSONArray jsonArray = new JSONArray();
			for (ConsumerCreditCardModel creditCard : creditCardls) {
				JSONObject creditCardJson = creditCard.toJSONObject();
				jsonArray.add(creditCardJson);
			}
			jsonObj.put("creditCardJson", jsonArray);
		}
		
		if (followupls != null && followupls.size() > 0) {
			JSONArray jsonArray = new JSONArray();
			for (ConsumerFollowupModel model : followupls) {
				JSONObject followup = model.toJSONObject();
				jsonArray.add(followup);
			}
			jsonObj.put("followup", jsonArray);
		}
		
		if (nextFollowupls != null && nextFollowupls.size() > 0) {
			JSONArray jsonArray = new JSONArray();
			for (ConsumerNextFollowupModel nextFlw : nextFollowupls) {
				JSONObject nextObj = nextFlw.toJSONObject();
				jsonArray.add(nextObj);
			}
			jsonObj.put("nextFollowupArr", jsonArray);
		}
		
		return jsonObj;
	}
	
	public JSONObject toLeaderGuideJSON(boolean needName) {
		JSONObject jsonObj = new JSONObject();
		jsonObj.put("id", this.id);		
		jsonObj.put("cliLevel", cliLevel);
		if (leaderGuide != null) {
			jsonObj.put("guide", leaderGuide);
		}
		if (needName) {
			if (name.length() > 0) {
				jsonObj.put("cliName", name);
			}
			if (phoneNum1.length() > 0) {
				jsonObj.put("cliPhoneNum1", phoneNum1);
			}
		}
		if (this.meetTalkTm != null) {
			long tm = this.meetTalkTm.getTime() / 1000;
			jsonObj.put("meetTalkTm", tm);
		}
		
		return jsonObj;
	}
	
	public void parseImportPurposeFromJson(JSONObject jsonData) {
		this.name = jsonData.getString("cliName");
		this.phoneNum1 = jsonData.getString("cliPhoneNum1");
		if (jsonData.containsKey("cliPhoneNum2")) {
			this.phoneNum2 = jsonData.getString("cliPhoneNum2");
		}
		if (jsonData.containsKey("memo")) {
			this.memo = jsonData.getString("memo");
		}
		if (jsonData.containsKey("cliType")) {
			this.cliType = jsonData.getString("cliType");
		}
		if (jsonData.containsKey("followupRecord")) {
			this.followupInfo = jsonData.getString("followupRecord");
		}
		if (jsonData.containsKey("followupTm")) {
			long tm = jsonData.getLongValue("followupTm")*1000;
			if (tm <= 0) {
				tm = System.currentTimeMillis();
			}
			this.lastfollowupTm = new Timestamp(tm);
		}
		if (jsonData.containsKey("devTm")) {
			long tm = jsonData.getLongValue("devTm")*1000;
			if (tm <= 0) {
				tm = System.currentTimeMillis();
			}
			this.devTime = new Timestamp(tm);
		}
		if (jsonData.containsKey("submitTm")) {
			long tm = jsonData.getLongValue("submitTm")*1000;
			if (tm <= 0) {
				tm = System.currentTimeMillis();
			}
			this.submitTm = new Timestamp(tm);			
		}
		
	}	
	
	public JSONObject toMeetTalkJSONObject() {
		JSONObject jsonObj = new JSONObject();
		jsonObj.put("id", this.id);
		jsonObj.put("userID", this.userID);
		jsonObj.put("cliName", this.name);
		jsonObj.put("cliPhoneNum1", phoneNum1);
		if (phoneNum2 != null && phoneNum2.length() > 0) {
			jsonObj.put("cliPhoneNum2", phoneNum2);
		}
		if (identityID != null && identityID.length() > 0) {
			jsonObj.put("identityID", identityID);
		}		
		if (submitTm != null) {
			long tm = submitTm.getTime() / 1000;
			jsonObj.put("submitTm", tm);
		}		
		if (status > 0) {
			jsonObj.put("status", status);
		}		
		
		return jsonObj;
	}

}
